package com.zhkj.shixi.tvplayer.adapter;

import com.zhkj.shixi.tvplayer.MusicPlayer.PlayerBackGround;
import com.zhkj.shixi.tvplayer.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;

/**
 * Created by suqiuyu on 19-8-20.
 */

public class PicBgAdapter extends ArrayAdapter<PlayerBackGround.Pic> {
    private  int resourceId;
    public PicBgAdapter(Context context, int resource, int textViewResourceId, List<PlayerBackGround.Pic> objects) {
        super(context, resource, textViewResourceId, objects);
        resourceId=resource;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PlayerBackGround.Pic pic=getItem(position);
        View view;
        ViewHoder viewHoder;
        if (convertView==null){
            view =LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
            viewHoder =new ViewHoder();
            viewHoder.picName =(TextView) view.findViewById(R.id.item_imagelist);
            view.setTag(viewHoder);
        }else {
            view =convertView;
            viewHoder =(ViewHoder)view.getTag();
        }
        viewHoder.picName.setText(pic.name);
        return view;
    }
}

class ViewHoder{
    TextView picName;
}
